load("//tools/build_defs/android:fb_xplat_android_cxx_library.bzl", "fb_xplat_android_cxx_library")
load("//tools/build_defs/oss:profilo_defs.bzl", "profilo_path")

fb_xplat_android_cxx_library(
    name = "manager",
    srcs = [
        "MmapBufferManager.cpp",
        "jni.cpp",
    ],
    header_namespace = "profilo/mmapbuf",
    exported_headers = [
        "MmapBufferManager.h",
    ],
    allow_jni_merging = True,
    compiler_flags = [
        "-fexceptions",
        "-frtti",
        "-std=gnu++14",
        "-DLOG_TAG=\"Profilo/Mmap\"",
    ],
    labels = [],
    soname = "libprofilo_mmapbuf.$(ext)",
    visibility = [
        profilo_path("..."),
    ],
    deps = [
        profilo_path("cpp/logger/buffer:buffer"),
        profilo_path("cpp:profilo"),
        profilo_path("deps/fb:fb"),
        profilo_path("deps/fbjni:fbjni"),
        profilo_path("deps/linker:locks"),
    ],
    exported_deps = [
        ":buffer",
        ":buffer_jni",
        profilo_path("cpp/mmapbuf/header:header"),
    ],
)

fb_xplat_android_cxx_library(
    name = "buffer",
    srcs = [
        "Buffer.cpp",
    ],
    header_namespace = "profilo/mmapbuf",
    exported_headers = [
        "Buffer.h",
    ],
    compiler_flags = [
        "-fexceptions",
        "-frtti",
        "-std=gnu++14",
        "-DLOG_TAG=\"Profilo/Buffer\"",
    ],
    labels = [],
    soname = "libprofilo_mmapbuf_buffer.$(ext)",
    visibility = [
        profilo_path("..."),
    ],
    deps = [
        profilo_path("cpp/mmapbuf/header:header"),
        profilo_path("cpp/logger/buffer:trace_buffer"),
        profilo_path("deps/fb:fb"),
    ],
    exported_deps = [
        profilo_path("cpp/logger:logger"),
    ],
)

fb_xplat_android_cxx_library(
    name = "buffer_jni",
    srcs = [
        "JBuffer.cpp",
    ],
    header_namespace = "profilo/mmapbuf",
    exported_headers = [
        "JBuffer.h",
    ],
    compiler_flags = [
        "-fexceptions",
        "-frtti",
        "-std=gnu++14",
        "-DLOG_TAG=\"Profilo/Buffer\"",
    ],
    labels = [],
    soname = "libprofilo_mmapbuf_buffer_jni.$(ext)",
    visibility = [
        profilo_path("..."),
    ],
    exported_deps = [
        ":buffer",
        profilo_path("deps/fb:fb"),
        profilo_path("deps/fbjni:fbjni"),
    ],
)
